package com.edais.actions;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.yunzhi.domain.ResultDTO;
import com.yunzhi.util.ResponseUtil;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.edais.service.TurnOutService;
import com.lb.sssq.actions.DepositAction;
import com.lb.sssq.util.CommonUtil;
import com.lb.sssq.util.Consts;
import com.lb.sssq.util.Message;

@Controller
@RequestMapping("/wxenjoy")

public class TurnOutInfo {
	private static final long serialVersionUID = -4830919067701566662L;
	private static final Log logger = LogFactory.getLog(TurnOutInfo.class);
	private TurnOutService turnOutService;
	
	@RequestMapping(value = "/getTurnOutInfo")
	public void getTurnOutInfo(HttpServletRequest request, HttpServletResponse response) throws Exception{
		Integer current = 1;
		Integer pageSize = 10;
		
		// 解密请求参数
		Map<String, String> paramsMap = CommonUtil.decryptParamters(request);
		String currentStr = paramsMap.get(Consts.Page.PAGE_CURRENT_NAME);   //当前页数
		String pageSizeStr = paramsMap.get(Consts.Page.PAGE_SIZE_NAME);     //页大小
		
		if(currentStr != null && !("".equals(currentStr))){
			current = Integer.parseInt(currentStr);
		}
		if(pageSizeStr != null && !("".equals(pageSizeStr))){
			pageSize = Integer.parseInt(pageSizeStr);
		}
		Map<String, Object> map = new HashMap<String, Object>();

		String userId = paramsMap.get("userId");

		if(StringUtils.isBlank(userId)){
			logger.error("查询转出记录数据检查失败：用户id为空" );
			String result = CommonUtil.setResultStringCn(new HashMap<String, Object>(),
					Consts.ERROR_CODE, Consts.ErrorMsg.MSG00001,
					"userId不能为空！");
			// 处理返回结果
			CommonUtil.responseJsonNotEncrypt(result, response);
			return;
		}

		map.put("current",current.toString());
		map.put("pageSize",pageSize.toString());
		map.put("userId", userId);
		//调用核心查询历史记录
		ResultDTO result = turnOutService.queryTurnOutList(map);
		ResponseUtil.write(response,  result);
		return;
	}
}
